{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import requests\n",
      "import json\n",
      "import pandas as pd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def query(end_point, params={}):\n",
      "    url = \"https://www.havelockinvestments.com/r/\" + end_point\n",
      "    req = requests.post(url, data=params, verify=False)\n",
      "    data = json.loads(req.content)\n",
      "    return(data)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "query('ticker', {})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 12,
       "text": [
        "{u'AM1': {u'last': u'2.15100000', u'units': u'1085'},\n",
        " u'AM100': {u'last': u'0.02064500', u'units': u'250761'},\n",
        " u'CBTC': {u'last': u'0.00039000', u'units': u'3000000'},\n",
        " u'CFIG': {u'last': u'0.13500001', u'units': u'200000'},\n",
        " u'DEALCO': {u'last': u'0.00800001', u'units': u'50000'},\n",
        " u'HIM': {u'last': u'0.15600000', u'units': u'40000'},\n",
        " u'KCIM': {u'last': u'0.35000000', u'units': u'907'},\n",
        " u'LABCO': {u'last': u'0.00228000', u'units': u'40000'},\n",
        " u'SDSTM': {u'last': u'0.00278999', u'units': u'100000'},\n",
        " u'SMG': {u'last': u'0.00020000', u'units': u'446532'},\n",
        " u'VTX': {u'last': u'0.60800000', u'units': u'10000'},\n",
        " u'XBOND': {u'last': u'0.00116000', u'units': u'2019576'}}"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "query('tickerfull', {})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 13,
       "text": [
        "{u'AM1': {u'1d': {u'btc': u'69.68410000',\n",
        "   u'max': u'2.24000000',\n",
        "   u'min': u'2.00000000',\n",
        "   u'vol': u'33',\n",
        "   u'vwap': 2.11163939},\n",
        "  u'30d': {u'btc': u'1628.30815069',\n",
        "   u'max': u'4.09000000',\n",
        "   u'min': u'1.92000000',\n",
        "   u'vol': u'614',\n",
        "   u'vwap': 2.65196767},\n",
        "  u'7d': {u'btc': u'243.04489900',\n",
        "   u'max': u'2.47499900',\n",
        "   u'min': u'2.00000000',\n",
        "   u'vol': u'110',\n",
        "   u'vwap': 2.20949908},\n",
        "  u'last': u'2.15100000',\n",
        "  u'name': u'ASICMINER Full Shares',\n",
        "  u'symbol': u'AM1',\n",
        "  u'units': u'1085'},\n",
        " u'AM100': {u'1d': {u'btc': u'17.28783654',\n",
        "   u'max': u'0.02109000',\n",
        "   u'min': u'0.01900001',\n",
        "   u'vol': u'865',\n",
        "   u'vwap': 0.01998594},\n",
        "  u'30d': {u'btc': u'1267.05594443',\n",
        "   u'max': u'0.03919898',\n",
        "   u'min': u'0.01850001',\n",
        "   u'vol': u'47421',\n",
        "   u'vwap': 0.0267193},\n",
        "  u'7d': {u'btc': u'171.64362220',\n",
        "   u'max': u'0.02320000',\n",
        "   u'min': u'0.01900001',\n",
        "   u'vol': u'8101',\n",
        "   u'vwap': 0.02118795},\n",
        "  u'last': u'0.02064500',\n",
        "  u'name': u'ASICMINER Fractional Shares',\n",
        "  u'symbol': u'AM100',\n",
        "  u'units': u'250761'},\n",
        " u'CBTC': {u'1d': {u'btc': u'21.53875510',\n",
        "   u'max': u'0.00042499',\n",
        "   u'min': u'0.00038003',\n",
        "   u'vol': u'53897',\n",
        "   u'vwap': 0.00039963},\n",
        "  u'30d': {u'btc': u'1247.41369171',\n",
        "   u'max': u'0.00057500',\n",
        "   u'min': u'0.00018000',\n",
        "   u'vol': u'5126477',\n",
        "   u'vwap': 0.00024333},\n",
        "  u'7d': {u'btc': u'1247.41369171',\n",
        "   u'max': u'0.00057500',\n",
        "   u'min': u'0.00018000',\n",
        "   u'vol': u'5126477',\n",
        "   u'vwap': 0.00024333},\n",
        "  u'last': u'0.00039000',\n",
        "  u'name': u'CasinoBitco.in',\n",
        "  u'symbol': u'CBTC',\n",
        "  u'units': u'3000000'},\n",
        " u'CFIG': {u'1d': {u'btc': u'3.25610001',\n",
        "   u'max': u'0.14500000',\n",
        "   u'min': u'0.13500001',\n",
        "   u'vol': u'23',\n",
        "   u'vwap': 0.14156957},\n",
        "  u'30d': {u'btc': u'855.24695321',\n",
        "   u'max': u'0.24000000',\n",
        "   u'min': u'0.12010000',\n",
        "   u'vol': u'5652',\n",
        "   u'vwap': 0.15131758},\n",
        "  u'7d': {u'btc': u'11.70215898',\n",
        "   u'max': u'0.15000000',\n",
        "   u'min': u'0.12872850',\n",
        "   u'vol': u'83',\n",
        "   u'vwap': 0.14098987},\n",
        "  u'last': u'0.13500001',\n",
        "  u'name': u'Crypto Financial',\n",
        "  u'symbol': u'CFIG',\n",
        "  u'units': u'200000'},\n",
        " u'DEALCO': {u'1d': {u'btc': u'0.32040531',\n",
        "   u'max': u'0.00810000',\n",
        "   u'min': u'0.00800001',\n",
        "   u'vol': u'40',\n",
        "   u'vwap': 0.00801013},\n",
        "  u'30d': {u'btc': u'626.60365121',\n",
        "   u'max': u'0.01900000',\n",
        "   u'min': u'0.00300000',\n",
        "   u'vol': u'61855',\n",
        "   u'vwap': 0.0101302},\n",
        "  u'7d': {u'btc': u'19.08557930',\n",
        "   u'max': u'0.01150000',\n",
        "   u'min': u'0.00800001',\n",
        "   u'vol': u'1974',\n",
        "   u'vwap': 0.00966848},\n",
        "  u'last': u'0.00800001',\n",
        "  u'name': u'Dealco.in',\n",
        "  u'symbol': u'DEALCO',\n",
        "  u'units': u'50000'},\n",
        " u'HIM': {u'1d': {u'btc': u'0.31200000',\n",
        "   u'max': u'0.15600000',\n",
        "   u'min': u'0.15600000',\n",
        "   u'vol': u'2',\n",
        "   u'vwap': 0.156},\n",
        "  u'30d': {u'btc': u'314.98073201',\n",
        "   u'max': u'0.22390000',\n",
        "   u'min': u'0.12600000',\n",
        "   u'vol': u'1615',\n",
        "   u'vwap': 0.19503451},\n",
        "  u'7d': {u'btc': u'25.16813617',\n",
        "   u'max': u'0.15600000',\n",
        "   u'min': u'0.13300000',\n",
        "   u'vol': u'171',\n",
        "   u'vwap': 0.14718208},\n",
        "  u'last': u'0.15600000',\n",
        "  u'name': u'Havelock Investments Mining Fund',\n",
        "  u'symbol': u'HIM',\n",
        "  u'units': u'40000'},\n",
        " u'KCIM': {u'1d': {u'btc': 0,\n",
        "   u'max': None,\n",
        "   u'min': None,\n",
        "   u'vol': 0,\n",
        "   u'vwap': 0},\n",
        "  u'30d': {u'btc': u'7.33350619',\n",
        "   u'max': u'0.88000000',\n",
        "   u'min': u'0.25990000',\n",
        "   u'vol': u'18',\n",
        "   u'vwap': 0.40741701},\n",
        "  u'7d': {u'btc': u'1.85000000',\n",
        "   u'max': u'0.35000000',\n",
        "   u'min': u'0.30000000',\n",
        "   u'vol': u'6',\n",
        "   u'vwap': 0.30833333},\n",
        "  u'last': u'0.35000000',\n",
        "  u'name': u'Korb and Co. Investments Mining Fund',\n",
        "  u'symbol': u'KCIM',\n",
        "  u'units': u'907'},\n",
        " u'LABCO': {u'1d': {u'btc': u'9.36798614',\n",
        "   u'max': u'0.00337299',\n",
        "   u'min': u'0.00228000',\n",
        "   u'vol': u'3482',\n",
        "   u'vwap': 0.0026904},\n",
        "  u'30d': {u'btc': u'137.56086840',\n",
        "   u'max': u'0.00398000',\n",
        "   u'min': u'0.00165000',\n",
        "   u'vol': u'47994',\n",
        "   u'vwap': 0.00286621},\n",
        "  u'7d': {u'btc': u'36.58617790',\n",
        "   u'max': u'0.00398000',\n",
        "   u'min': u'0.00228000',\n",
        "   u'vol': u'11665',\n",
        "   u'vwap': 0.00313641},\n",
        "  u'last': u'0.00228000',\n",
        "  u'name': u'Labcoin Passthru',\n",
        "  u'symbol': u'LABCO',\n",
        "  u'units': u'40000'},\n",
        " u'SDSTM': {u'1d': {u'btc': u'0.46156727',\n",
        "   u'max': u'0.00287330',\n",
        "   u'min': u'0.00242000',\n",
        "   u'vol': u'186',\n",
        "   u'vwap': 0.00248154},\n",
        "  u'30d': {u'btc': u'34.44531455',\n",
        "   u'max': u'0.00626290',\n",
        "   u'min': u'0.00232000',\n",
        "   u'vol': u'8793',\n",
        "   u'vwap': 0.00391736},\n",
        "  u'7d': {u'btc': u'5.17974894',\n",
        "   u'max': u'0.00312000',\n",
        "   u'min': u'0.00232000',\n",
        "   u'vol': u'2011',\n",
        "   u'vwap': 0.00257571},\n",
        "  u'last': u'0.00278999',\n",
        "  u'name': u'Sandstorm',\n",
        "  u'symbol': u'SDSTM',\n",
        "  u'units': u'100000'},\n",
        " u'SMG': {u'1d': {u'btc': u'0.00060000',\n",
        "   u'max': u'0.00020000',\n",
        "   u'min': u'0.00020000',\n",
        "   u'vol': u'3',\n",
        "   u'vwap': 0.0002},\n",
        "  u'30d': {u'btc': u'12.39269725',\n",
        "   u'max': u'0.00026700',\n",
        "   u'min': u'0.00017005',\n",
        "   u'vol': u'60648',\n",
        "   u'vwap': 0.00020434},\n",
        "  u'7d': {u'btc': u'0.87854112',\n",
        "   u'max': u'0.00021999',\n",
        "   u'min': u'0.00017500',\n",
        "   u'vol': u'4753',\n",
        "   u'vwap': 0.00018484},\n",
        "  u'last': u'0.00020000',\n",
        "  u'name': u'S.MG Passthru from MPEX',\n",
        "  u'symbol': u'SMG',\n",
        "  u'units': u'446532'},\n",
        " u'VTX': {u'1d': {u'btc': u'15.00699940',\n",
        "   u'max': u'0.60800000',\n",
        "   u'min': u'0.58900000',\n",
        "   u'vol': u'25',\n",
        "   u'vwap': 0.60027998},\n",
        "  u'30d': {u'btc': u'288.67968396',\n",
        "   u'max': u'0.65849990',\n",
        "   u'min': u'0.55300000',\n",
        "   u'vol': u'488',\n",
        "   u'vwap': 0.59155673},\n",
        "  u'7d': {u'btc': u'39.81298940',\n",
        "   u'max': u'0.60800000',\n",
        "   u'min': u'0.55500000',\n",
        "   u'vol': u'69',\n",
        "   u'vwap': 0.57699985},\n",
        "  u'last': u'0.60800000',\n",
        "  u'name': u'VirtEx Canadian Bitcoin Exchange',\n",
        "  u'symbol': u'VTX',\n",
        "  u'units': u'10000'},\n",
        " u'XBOND': {u'1d': {u'btc': u'9.54856163',\n",
        "   u'max': u'0.00119000',\n",
        "   u'min': u'0.00115500',\n",
        "   u'vol': u'8051',\n",
        "   u'vwap': 0.00118601},\n",
        "  u'30d': {u'btc': u'429.58976479',\n",
        "   u'max': u'0.00142350',\n",
        "   u'min': u'0.00100000',\n",
        "   u'vol': u'385756',\n",
        "   u'vwap': 0.00111363},\n",
        "  u'7d': {u'btc': u'115.70742353',\n",
        "   u'max': u'0.00119000',\n",
        "   u'min': u'0.00105000',\n",
        "   u'vol': u'101280',\n",
        "   u'vwap': 0.00114245},\n",
        "  u'last': u'0.00116000',\n",
        "  u'name': u'XBOND - Exchangeable Fixed-Rate Bond',\n",
        "  u'symbol': u'XBOND',\n",
        "  u'units': u'2019576'}}"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "query('dividends', {'symbol': 'KCIM'})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 11,
       "text": [
        "{u'dividends': [{u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2012-11-05',\n",
        "   u'paydate': u'2012-11-30'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2012-12-04',\n",
        "   u'paydate': u'2012-12-31'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-01-04',\n",
        "   u'paydate': u'2013-01-31'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-02-02',\n",
        "   u'paydate': u'2013-02-28'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-03-02',\n",
        "   u'paydate': u'2013-03-31'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-04-02',\n",
        "   u'paydate': u'2013-04-30'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-05-02',\n",
        "   u'paydate': u'2013-05-31'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-06-03',\n",
        "   u'paydate': u'2013-06-30'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-07-02',\n",
        "   u'paydate': u'2013-07-31'},\n",
        "  {u'amount': u'0.01000000',\n",
        "   u'announcedate': u'2013-08-02',\n",
        "   u'paydate': u'2013-08-31'},\n",
        "  {u'amount': u'0.00500000',\n",
        "   u'announcedate': u'2013-09-02',\n",
        "   u'paydate': u'2013-09-30'}],\n",
        " u'status': u'ok'}"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "query('orderbook', {'symbol': 'KCIM'})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 15,
       "text": [
        "{u'asks': {u'0.49999000': u'1',\n",
        "  u'0.50000000': u'12',\n",
        "  u'0.67000000': u'1',\n",
        "  u'0.80000000': u'1',\n",
        "  u'0.84600000': u'10',\n",
        "  u'0.84800000': u'10',\n",
        "  u'0.94990000': u'2',\n",
        "  u'0.99990000': u'10',\n",
        "  u'1.03000000': u'14',\n",
        "  u'1.12500000': u'32',\n",
        "  u'1.14000000': u'1',\n",
        "  u'1.16600000': u'16',\n",
        "  u'1.17000000': u'1',\n",
        "  u'1.20000000': u'16',\n",
        "  u'1.22000000': u'1',\n",
        "  u'1.45000000': u'1',\n",
        "  u'1.48000000': u'1',\n",
        "  u'1.63770000': u'1',\n",
        "  u'2.00000000': u'2'},\n",
        " u'bids': {u'0.00100000': u'1000',\n",
        "  u'0.02900000': u'11',\n",
        "  u'0.08800000': u'100',\n",
        "  u'0.09000000': u'2',\n",
        "  u'0.20000000': u'15',\n",
        "  u'0.22000000': u'8',\n",
        "  u'0.33000000': u'1'},\n",
        " u'status': u'ok'}"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "query('orderbookfull', {'symbol': 'KCIM'})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 16,
       "text": [
        "{u'asks': {u'100848': {u'amount': u'2',\n",
        "   u'id': u'100848',\n",
        "   u'price': u'2.00000000'},\n",
        "  u'105787': {u'amount': u'6', u'id': u'105787', u'price': u'1.20000000'},\n",
        "  u'120928': {u'amount': u'10', u'id': u'120928', u'price': u'1.20000000'},\n",
        "  u'121287': {u'amount': u'1', u'id': u'121287', u'price': u'1.14000000'},\n",
        "  u'121728': {u'amount': u'10', u'id': u'121728', u'price': u'0.99990000'},\n",
        "  u'147521': {u'amount': u'2', u'id': u'147521', u'price': u'0.94990000'},\n",
        "  u'158081': {u'amount': u'1', u'id': u'158081', u'price': u'1.22000000'},\n",
        "  u'165969': {u'amount': u'32', u'id': u'165969', u'price': u'1.12500000'},\n",
        "  u'170074': {u'amount': u'1', u'id': u'170074', u'price': u'0.80000000'},\n",
        "  u'171698': {u'amount': u'10', u'id': u'171698', u'price': u'0.84800000'},\n",
        "  u'171700': {u'amount': u'10', u'id': u'171700', u'price': u'0.84600000'},\n",
        "  u'176786': {u'amount': u'1', u'id': u'176786', u'price': u'0.67000000'},\n",
        "  u'177715': {u'amount': u'12', u'id': u'177715', u'price': u'0.50000000'},\n",
        "  u'179026': {u'amount': u'1', u'id': u'179026', u'price': u'0.49999000'},\n",
        "  u'18457': {u'amount': u'1', u'id': u'18457', u'price': u'1.48000000'},\n",
        "  u'27028': {u'amount': u'1', u'id': u'27028', u'price': u'1.45000000'},\n",
        "  u'43533': {u'amount': u'1', u'id': u'43533', u'price': u'1.17000000'},\n",
        "  u'44960': {u'amount': u'16', u'id': u'44960', u'price': u'1.16600000'},\n",
        "  u'52901': {u'amount': u'14', u'id': u'52901', u'price': u'1.03000000'},\n",
        "  u'68316': {u'amount': u'1', u'id': u'68316', u'price': u'1.63770000'}},\n",
        " u'bids': {u'165764': {u'amount': u'11',\n",
        "   u'id': u'165764',\n",
        "   u'price': u'0.02900000'},\n",
        "  u'165811': {u'amount': u'100', u'id': u'165811', u'price': u'0.08800000'},\n",
        "  u'167412': {u'amount': u'15', u'id': u'167412', u'price': u'0.20000000'},\n",
        "  u'171491': {u'amount': u'2', u'id': u'171491', u'price': u'0.09000000'},\n",
        "  u'172477': {u'amount': u'8', u'id': u'172477', u'price': u'0.22000000'},\n",
        "  u'179186': {u'amount': u'1000', u'id': u'179186', u'price': u'0.00100000'},\n",
        "  u'179601': {u'amount': u'1', u'id': u'179601', u'price': u'0.33000000'}},\n",
        " u'status': u'ok'}"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}